<template>
    <slot :controller="controller" :store="store" :model="model" :noPadding="noPadding">
        <div :id="controlID" :name="model.codeName" :class="classNames" style="">
            <AppDashboard v-bind="$attrs" :noPadding="noPadding" :layoutOpts="model.layoutOpts">
            </AppDashboard>
        </div>
    </slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@DASHBOARD}}-dashboard/{{spinalCase ctrl.codeName}}-dashboard-base.vue.hbs生成
import { AppDashboard } from '@components/widgets/dashboard';
import { useProps, useBasic, useAction, useController } from './portal-db-dashboard-hook';
import { DashboardActionType, IDashboardAbility, IDashboardStore, IParam } from "@/core/interface";
// 输入参数
const props = defineProps(useProps());

// 基础数据
const { 
    model,
    controlID, 
    getClassNames, 
    useNavParamsBind, 
    useEventBind, 
    handleCtrlDestroy,
    handleCtrlInit, 
    handleCtrlAction,
} = useBasic(props);

const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: DashboardActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: IDashboardAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
    return getClassNames(props);
});

const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: IDashboardStore = controller.getStore();

onMounted(() => {
    controller.ctrlMounted();
});

onUnmounted(() => {
    controller.ctrlDestroy();
})
</script>